package com.antd.auth.fegin.fallback;

import cn.hutool.http.HttpStatus;
import com.antd.admin.api.entity.SysMenu;
import com.antd.admin.api.entity.SysUser;
import com.antd.auth.fegin.RemotePermissionService;
import com.antd.auth.fegin.RemoteUserService;
import com.antd.common.core.util.R;
import com.netflix.client.ClientException;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2020/11/19 10:07
 */
@Slf4j
@AllArgsConstructor
public class RemotePermissionFallbackImpl implements RemotePermissionService {
    private final Throwable throwable;
    @Override
    public R<List<SysMenu>> findPermission() {
        Throwable cause = throwable.getCause();
        if(cause instanceof ClientException){
            return R.error(HttpStatus.HTTP_NOT_FOUND,"系统异常,请稍后再试！");
        }
        return R.error("服务器异常");
    }

}
